﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace BarcodeDelay.utility
{
    public static class MathUtility
    {
        private static string m_errorInfo = string.Empty;
        /// <summary>
        /// 判断是否闰年
        /// </summary>
        /// <param name="stryear"></param>
        /// <returns></returns>
        public static bool IsRunYear(string stryear)
        {
            try
            {
                int year = Convert.ToInt32(stryear);
                if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 判断年份是否合法
        /// </summary>
        /// <param name="strYear"></param>
        /// <returns></returns>
        public static bool CheckYear(string strYear)
        {
            try
            {
                int year = Convert.ToInt32(strYear);
                if (year < 1900 || year > 2050)
                {
                    return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 检测年份与月份
        /// </summary>
        /// <param name="strYear"></param>
        /// <param name="strMonth"></param>
        /// <returns></returns>
        public static bool CheckYearAndMonth(string strYear, string strMonth)
        {
            try
            {
                int year = Convert.ToInt32(strYear);
                int month = Convert.ToInt32(strMonth);
                if (year < 1900 || year > 2050)
                {
                    return false;
                }
                if (month < 1 || month > 12)
                {
                    return false;
                }
                if (month < 10 && strMonth.Length != 1)
                {
                    return false;
                }
                if (month > 10 && strMonth.Length != 2)
                {
                    return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }

        }
        /// <summary>
        /// 经纬度检测
        /// </summary>
        /// <param name="longti"></param>
        /// <param name="lati"></param>
        /// <returns></returns>
        public static bool IsRightPos(string longti, string lati)
        {
            try
            {
                if (longti.IndexOf('°') <= 0 || longti.IndexOf('′') <= 0)
                {
                    return false;
                }
                if (lati.IndexOf('°') <= 0 || lati.IndexOf('′') <= 0)
                {
                    return false;
                }
                string strLongDu = string.Empty;
                string strLongMiao = string.Empty;
                string strLatDu = string.Empty;
                string strlatMiao = string.Empty;
                strLongDu = longti.Substring(0, longti.IndexOf('°'));
                strLongMiao = longti.Substring(longti.IndexOf('°') + 1, longti.IndexOf('′') - longti.IndexOf('°') - 1);
                strLatDu = lati.Substring(0, lati.IndexOf('°'));
                strlatMiao = lati.Substring(lati.IndexOf('°') + 1, lati.IndexOf('′') - lati.IndexOf('°') - 1);
                int intLongDu = Convert.ToInt32(strLongDu);
                int intLatDu = Convert.ToInt32(strLatDu);
                int intLongMiao = Convert.ToInt32(strLongMiao);
                int intLatMiao = Convert.ToInt32(strlatMiao);
                if (intLongDu < 73 || intLongDu > 135)
                {
                    return false;
                }
                if (intLatDu < 3 || intLatDu > 53)
                {
                    return false;
                }
                if (intLongMiao >= 60 || intLatMiao >= 60)
                {
                    return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }



        }
        /// <summary>
        /// 返回匹配字符最多的字符串
        /// </summary>
        /// <param name="strInput"></param>
        /// <returns></returns>
        public static string GetMaxMatchString(string[] strInput)
        {
            try
            {
                if (strInput.Count() == 0)
                {
                    return string.Empty;
                }
                Dictionary<string, int> dic = new Dictionary<string, int>();

                foreach (string c in strInput)
                {
                    if (c != null)
                    {
                        if (!dic.ContainsKey(c))
                        {
                            dic.Add(c, 1);
                        }
                        else
                        {
                            dic[c] = dic[c] + 1;
                        }
                    }
                }
                int maxCount = 0;
                string maxVal = string.Empty;
                foreach (KeyValuePair<string, int> item in dic)
                {
                    //Console.WriteLine("{0}出现{1}次", item.Key, item.Value);
                    if (maxCount < item.Value)
                    {
                        maxVal = item.Key.ToString();
                        maxCount = item.Value;
                    }
                    //MessageBox.Show(item.Key.ToString() + "出现" + item.Value.ToString());
                }
                return maxVal;
            }
            catch (Exception ex)
            {
                return string.Empty;
            }

        }

        public static string GetAvergaeInterPart(string[] strInput)
        {
            string strResult = string.Empty;
            try
            {
                int count = 0;
                int sum = 0;
                foreach (string strVal in strInput)
                {
                    if (MathUtility.ImpIsNum(strVal))
                    {
                        count++;
                        sum = sum + Convert.ToInt32(strVal);
                    }
                }
                if (sum > 0)
                {
                    strResult = (sum / count).ToString();
                }
                return strResult;
            }
            catch (Exception ex)
            {
                return strResult;
            }
        }
        /// <summary>
        /// 返回匹配字符最多的字符
        /// </summary>
        /// <param name="strInput"></param>
        /// <returns></returns>
        public static string GetMaxMatchChar(string strInput)
        {
            if (strInput == "" || strInput == string.Empty)
            {
                return string.Empty;
            }
            Dictionary<char, int> dic = new Dictionary<char, int>();
            char[] chardata = strInput.ToCharArray();

            foreach (char c in chardata)
            {
                if (!dic.ContainsKey(c))
                {
                    dic.Add(c, 1);
                }
                else
                {
                    dic[c] = dic[c] + 1;
                }
            }
            int maxCount = 1;
            string maxVal = string.Empty;
            foreach (KeyValuePair<char, int> item in dic)
            {
                //Console.WriteLine("{0}出现{1}次", item.Key, item.Value);
                if (maxCount < item.Value)
                {
                    maxVal = item.Key.ToString();
                    maxCount = item.Value;
                }
                //MessageBox.Show(item.Key.ToString() + "出现" + item.Value.ToString());
            }
            return maxVal;

        }
        /// <summary>
        /// 判断输入是否为纯汉字
        /// </summary>
        /// <param name="strInput"></param>
        /// <returns></returns>
        public static bool IsChinese(string strInput)
        {
            return System.Text.RegularExpressions.Regex.IsMatch(strInput, @"[\u4e00-\u9fa5]+$");
        }
        /// <summary>
        /// 判断输入是否为纯数字
        /// </summary>
        /// <param name="srcStr"></param>
        /// <returns></returns>
        public static bool ImpIsNum(String srcStr)
        {
            //if (srcStr.Contains("178"))
            //{
            //    srcStr = "178";
            //}
            ////if (srcStr.Contains("178"))
            ////{
            ////    int a = 0;
            ////}

            Regex regIsNum = new Regex(@"^\d+$");
            if (regIsNum.IsMatch(srcStr))
            {
                return true;
            }
            return false;
        }

        /// <summary>
        /// 判断输入是否为数字或小数
        /// </summary>
        /// <param name="srcStr"></param>
        /// <returns></returns>
        public static bool ImpIsNumOrVal(String srcStr)
        {
            string val = srcStr;
            if (srcStr.Contains('.'))
            {
                val = srcStr.Replace(".", "");
            }
            if (ImpIsNum(val))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 四舍五入六考虑
        /// </summary>
        /// <param name="val">待转化的数值</param>
        /// <param name="declength">取用精度</param>
        /// <returns></returns>
        public static decimal convertValue(string val, int declength)
        {
            try
            {
                decimal conv = 0;
                //conv = Math.Round(Convert.ToDouble(val), declength);
                conv = Math.Round(Convert.ToDecimal(val), declength);

                return conv;
            }
            catch (Exception ex)
            {
                return 0;
            }
        }
        /// <summary>
        /// 至河口距离，大于等于10km，则记至1km，小于10km，则记至0.1km
        /// </summary>
        /// <param name="val">河口距离</param>
        /// <returns></returns>
        public static bool lengthToRiverMouth(string val)
        {
            try
            {
                decimal decVal = Convert.ToDecimal(val);
                if (decVal >= 10)
                {
                    if (val.IndexOf('.') > 0)
                    {
                        return false;
                    }
                }
                else if (decVal >= 0 && decVal < 10)
                {
                    if (val.IndexOf('.') < 0)
                    {
                        return false;
                    }
                    else
                    {
                        if (val.Length - val.IndexOf('.') - 1 > 1)
                        {
                            return false;
                        }
                    }

                }

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }

        }
        /// <summary>
        /// 集水面积
        /// </summary>
        /// <param name="val">集水面积</param>
        /// <returns></returns>
        public static bool squareRiver(string val)
        {
            try
            {
                decimal decVal = Convert.ToDecimal(val);
                if (decVal >= 100)
                {
                    if (val.IndexOf('.') > 0)
                    {
                        return false;
                    }
                }
                else if (decVal >= 10 && decVal < 100)
                {
                    if (val.IndexOf('.') < 0)
                    {
                        return false;
                    }
                    else
                    {
                        if (val.Length - val.IndexOf('.') - 1 != 1)
                        {
                            return false;
                        }
                    }

                }
                else if (decVal >= 0 && decVal < 10)
                {
                    if (val.IndexOf('.') < 0)
                    {
                        return false;
                    }
                    else
                    {
                        if (val.Length - val.IndexOf('.') - 1 != 2)
                        {
                            return false;
                        }
                    }
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 基面，水准点高程
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static bool heightOfBasicRiver(string val)
        {
            try
            {
                decimal decVal = Convert.ToDecimal(val);
                if (val.Length - val.IndexOf('.') - 1 != 3)
                {
                    return false;
                }

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        /// <summary>
        /// 返回正确的断面面积格式，取3位有效数字，小数不过2位
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static string getRightFormatSquare(string val)
        {
            try
            {
                val = val.Replace("(", "");
                val = val.Replace(")", "");
                string strReturnVal = string.Empty;
                if (val.Contains('.'))
                {
                    if (val.Substring(0, val.IndexOf('.')) != "0")
                    {
                        int length = 3 - val.IndexOf('.');
                        decimal va = convertValue(val, length);

                        return va.ToString();
                        //return val.Substring(0, 4);
                    }
                    else
                    {
                        //string v = val.Substring(0, 6);
                        decimal va = convertValue(val, 2);
                        return va.ToString();
                        //return val.Substring(0, 5);
                    }
                }
                else
                {
                    int length = val.Length;
                    if (length == 1)
                    {
                        strReturnVal = val + ".00";
                    }
                    if (length == 2)
                    {
                        strReturnVal = val + ".0";
                    }
                    if (length == 3)
                    {
                        strReturnVal = val;
                    }
                    if (length > 3)
                    {
                        string strConv = val.Substring(0, 3);
                        string strTemp = val.Substring(3, val.Length - 3);
                        char[] arrChar = strTemp.ToCharArray();
                        foreach (char c in arrChar)
                        {
                            strConv += "0";
                        }
                        strReturnVal = strConv;
                    }
                    return strReturnVal;

                }
            }
            catch (Exception ex)
            {
                return string.Empty;
            }
        }

        /// <summary>
        /// 返回正确的流速格式，>=1m/s,三位有效数字，小于1m/s，两位有效数字，小数不过三位
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static string getRightFormatLS(string val)
        {
            try
            {
                string strReturnVal = string.Empty;
                if (val.Contains('.'))
                {
                    if (val.Substring(0, val.IndexOf('.')) != "0")
                    {
                        int length = 3 - val.IndexOf('.');
                        decimal va = convertValue(val, length);

                        return va.ToString();
                        //return val.Substring(0, 4);
                    }
                    else
                    {
                        //string v = val.Substring(0, 6);
                        string strTemp = val.Substring(2, val.Length - 2);
                        char[] arrChar = strTemp.ToCharArray();
                        int index = 0;
                        foreach (char c in arrChar)
                        {
                            if (c == '0')
                                index++;
                            else
                                break;
                        }
                        decimal va = convertValue(val, 2 + index);
                        string strVal = va.ToString();
                        if (va.ToString().Length == 3)
                        {
                            strVal += "0";
                        }
                        if (va.ToString().Length == 5)
                        {
                            if (va < 1 && va.ToString().EndsWith("00"))
                            {
                                string valr = strVal.Substring(4, 1);
                                if (valr == "0")
                                {
                                    strVal = strVal.Substring(0, 4);
                                }
                            }


                        }
                        if (va.ToString().Length == 6)
                        {
                            decimal dstrVal = convertValue(strVal, 3);
                            string v5 = strVal.Substring(5, 1);
                            decimal dstrval = Convert.ToDecimal(strVal);
                            if (Convert.ToInt32(v5) > 5)
                            {
                                strVal = strVal.Substring(0, 5);
                                dstrval = Convert.ToDecimal(strVal) + (decimal)0.001;
                            }
                            string valr = dstrval.ToString();

                            strVal = valr.Substring(0, 5);

                        }
                        return strVal;
                        //return val.Substring(0, 5);
                    }
                }
                else
                {
                    int length = val.Length;
                    if (length == 1)
                    {
                        strReturnVal = val + ".00";
                    }
                    if (length == 2)
                    {
                        strReturnVal = val + ".0";
                    }
                    if (length == 3)
                    {
                        strReturnVal = val;
                    }
                    if (length > 3)
                    {
                        string strConv = val.Substring(0, 3);
                        string strTemp = val.Substring(3, val.Length - 3);
                        char[] arrChar = strTemp.ToCharArray();
                        foreach (char c in arrChar)
                        {
                            strConv += "0";
                        }
                        strReturnVal = strConv;
                    }
                    return strReturnVal;

                }
            }
            catch (Exception ex)
            {
                return string.Empty;
            }
        }

        /// <summary>
        /// 返回正确的流量数据格式，取3位有效数字，小数不过3位
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static string getRightFormatMonthQAT(string val)
        {
            try
            {
                string strReturnVal = string.Empty;
                string flag = "";
                if (val.Contains("-"))
                {
                    flag = "-";
                    val = val.Substring(1);
                }
                if (isRightDigital(val))
                {
                    decimal dval = Convert.ToDecimal(val);
                    if (Math.Abs(dval) > 100)
                    {
                        if (val.Contains("."))
                        {
                            //val = convertValue(val, 0).ToString();

                            string dig = val.Substring(val.IndexOf(".") + 1);
                            val = val.Substring(0, val.IndexOf("."));
                            string c1 = "";
                            string c2 = "";
                            if (dig.Length == 1)
                            {
                                c1 = dig;
                            }
                            if (dig.Length > 1)
                            {
                                c1 = dig.Substring(0, 1);
                                c2 = dig.Substring(1, 1);
                            }
                            int ic1 = Convert.ToInt32(c1);
                            int ic2 = 0;
                            if (c2 != "")
                            {
                                ic2 = Convert.ToInt32(c2);
                            }
                            if (ic1 > 5)
                            {
                                val = (Convert.ToInt32(val) + 1).ToString();
                            }
                            bool bflag = false;
                            if (ic1 == 5)
                            {
                                //if (ic2 % 2 != 0)
                                //{
                                //    val = (Convert.ToInt32(val) + 1).ToString();
                                //}
                                if (dig.Length > 1)
                                {
                                    dig = dig.Substring(1);
                                    Array arrChar = dig.ToArray();
                                    foreach (char c in arrChar)
                                    {
                                        if (c != '0')
                                            bflag = true;
                                        else
                                            continue; ;
                                    }
                                    if (bflag)
                                    {
                                        val = (Convert.ToInt32(val) + 1).ToString();
                                    }
                                    else
                                    {
                                        string strc = val.Substring(val.Length - 1);
                                        int nsrc = Convert.ToInt32(strc);
                                        if (nsrc % 2 != 0)
                                        {
                                            val = (Convert.ToInt32(val) + 1).ToString();
                                        }
                                    }
                                }


                            }
                        }
                        char[] arr = val.ToCharArray();
                        int index = 1;
                        string result = string.Empty;
                        int addStep = 0;
                        bool flagStep = false;
                        foreach (char c in arr)
                        {
                            char newchar = c;
                            if (index > 3)
                            {
                                newchar = '0';
                            }
                            if (index == 4)
                            {
                                string strStep = c.ToString();
                                if (Convert.ToInt32(strStep) > 5)
                                {
                                    addStep = 1;
                                }
                                if (Convert.ToInt32(strStep) == 5)
                                {
                                    flagStep = true;

                                }
                            }
                            if (index == 5)
                            {
                                string strStep = c.ToString();
                                if (flagStep)
                                {
                                    if (Convert.ToInt32(strStep) % 2 != 0)
                                    {
                                        addStep = 1;
                                    }
                                }
                            }

                            result = result + newchar.ToString();
                            index++;
                        }
                        val = result;
                        if (val.Length > 3)
                        {
                            string val1 = val.Substring(0, 3);
                            string val2 = val.Substring(3);
                            val1 = (Convert.ToInt32(val1) + addStep).ToString();
                            val = val1 + val2;
                        }
                    }



                }
                if (val.Contains('.'))
                {

                    if (val.Substring(0, val.IndexOf('.')) != "0")
                    {
                        int length = 3 - val.IndexOf('.');
                        int sublen = val.Length - val.IndexOf('.') - 1;
                        if (length > sublen)
                        {
                            val = val + "0";
                        }
                        decimal va = convertValue(val, length);

                        return flag + va.ToString();
                        //return val.Substring(0, 4);
                    }
                    else
                    {
                        //string v = val.Substring(0, 6);
                        if (1 != 0)
                        {
                            if (val.Length == 4)
                            {
                                val = val + "0";
                            }
                            if (val.Length == 3)
                            {
                                val = val + "00";
                            }
                            decimal va = convertValue(val, 3);
                            string strTemp = va.ToString();
                            if (strTemp.Contains("1."))
                            {
                                strTemp = strTemp.Substring(0, 4);
                            }
                            return flag + strTemp;
                        }
                        else
                        {
                            if (Math.Abs(Convert.ToDecimal(val)) >= (decimal)0.1 && Math.Abs(Convert.ToDecimal(val)) < 1)
                            {
                                if (val.Length == 3)
                                {
                                    val = val + "0";
                                }
                                decimal va = convertValue(val, 2);
                                string strTemp = va.ToString();
                                if (strTemp.Contains("1."))
                                {
                                    strTemp = strTemp.Substring(0, 4);
                                }
                                return flag + strTemp;

                            }
                            else
                            {
                                if (val.Length == 4)
                                {
                                    val = val + "0";
                                }
                                if (val.Length == 3)
                                {
                                    val = val + "00";
                                }
                                decimal va = convertValue(val, 3);
                                string strTemp = va.ToString();
                                if (strTemp.Contains("1."))
                                {
                                    strTemp = strTemp.Substring(0, 4);
                                }
                                return flag + strTemp;
                            }
                        }
                        //return val.Substring(0, 5);
                    }
                }
                else
                {
                    return flag + val;
                }
            }
            catch (Exception ex)
            {
                return string.Empty;
            }
        }
        /// <summary>
        /// 计算结果与实际结果误差是否在5%以内
        /// </summary>
        /// <param name="Compureresust"></param>
        /// <param name="originalResult"></param>
        /// <returns></returns>
        public static bool isResultRight(decimal Compureresust, decimal originalResult)
        {
            try
            {
                if (Compureresust == 0 && originalResult == 0)
                {
                    return true;
                }
                if (originalResult == 0)
                {
                    return false;
                }
                decimal abs = Math.Abs(Compureresust - originalResult);
                decimal result = abs / originalResult;
                if (result <= (decimal)0.05)
                    return true;
                else
                    return false;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 返回正确的径流量数据格式,取4位有效数字，小数不过4位
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static string getRightFormatQATJLL(string val)
        {
            try
            {
                string strReturnVal = string.Empty;
                string flag = string.Empty;
                if (val.Contains("-"))
                {
                    if (val.IndexOf("-") == 0)
                    {
                        flag = "-";
                        val = val.Substring(1);
                    }
                }
                if (val.Contains('.'))
                {
                    if (val.Substring(0, val.IndexOf('.')) != "0")
                    {
                        int length = 4 - val.IndexOf('.');
                        decimal va = convertValue(val, length);

                        return flag + va.ToString();
                        //return val.Substring(0, 4);
                    }
                    else
                    {
                        //string v = val.Substring(0, 6);
                        decimal va = convertValue(val, 4);
                        return flag + va.ToString();
                        //return val.Substring(0, 5);
                    }
                }
                else
                {
                    return flag + val;
                }
            }
            catch (Exception ex)
            {
                return string.Empty;
            }
        }

        /// <summary>
        /// 三位有效数字
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static bool isRightFormatMonthQAT(string val)
        {

            try
            {
                string tr = val.Replace("-", "");
                if (!isRightDigital(tr))
                {
                    return false;
                }
                if (val.Contains('-'))
                {
                    val = val.Replace("-", "");
                }
                if (!isRightDigital(val))
                {
                    return false;
                }

                if (val.Contains('.'))
                {
                    decimal decVal = Convert.ToDecimal(val);
                    string interPart = val.Substring(0, val.IndexOf('.'));
                    if (interPart != "0")
                    {
                        if (val.Length != 4)
                            return false;
                    }
                    else
                    {
                        if (1 != 0)
                        {
                            if (val.Length != 5)
                                return false;
                        }
                        //设置是否设定为大于等于0.10且小于1时，取两位有效数字，为0.22 而非0.220的形式
                        else
                        {
                            if (Convert.ToDecimal(val) >= (decimal)0.1 && Convert.ToDecimal(val) < 1)
                            {
                                if (val.Length != 4)
                                {
                                    return false;
                                }
                            }
                            else
                            {
                                if (val.Length != 5)
                                    return false;
                            }
                        }
                    }
                }
                else
                {
                    if (val.Length > 3)
                    {
                        string strTemp = val.Substring(3, val.Length - 3);
                        char[] arrChar = strTemp.ToCharArray();
                        foreach (char c in arrChar)
                        {
                            if (c != '0')
                                return false;
                        }
                    }
                    if (val.Length < 3 && val != "0")
                    {
                        return false;
                    }

                }


                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }


        /// <summary>
        /// 四位有效数字
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static bool isRightFormatJLL(string val)
        {

            try
            {
                if (val.Contains('-'))
                {
                    val = val.Replace("-", "");
                }
                if (val.Contains('.'))
                {
                    decimal decVal = Convert.ToDecimal(val);
                    string interPart = val.Substring(0, val.IndexOf('.'));
                    if (interPart != "0")
                    {
                        if (val.Length != 5)
                            return false;
                    }
                    else
                    {
                        if (val.Length != 6)
                            return false;
                    }
                }
                else
                {
                    if (val.Length > 4)
                    {
                        string strTemp = val.Substring(4, val.Length - 4);
                        char[] arrChar = strTemp.ToCharArray();
                        foreach (char c in arrChar)
                        {
                            if (c != '0')
                                return false;
                        }
                    }
                }


                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }


        /// <summary>
        /// 三位有效数字，小数不过2位
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static bool isRightFormatSquare(string val)
        {

            try
            {
                if (val.Contains('-'))
                {
                    val = val.Replace("-", "");
                }
                if (val.Contains('.'))
                {
                    decimal decVal = Convert.ToDecimal(val);
                    string interPart = val.Substring(0, val.IndexOf('.'));
                    if (interPart != "0")
                    {
                        if (val.Length != 4)
                            return false;
                    }
                    else
                    {
                        if (val.Length != 4)
                            return false;
                    }
                }
                else
                {
                    if (val.Length > 3)
                    {
                        string strTemp = val.Substring(3, val.Length - 3);
                        char[] arrChar = strTemp.ToCharArray();
                        foreach (char c in arrChar)
                        {
                            if (c != '0')
                                return false;
                        }
                    }
                }


                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }


        /// <summary>
        /// 三位有效数字，小数不过1位
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static bool isRightFormatWidth(string val)
        {

            try
            {
                if (val.Contains('-'))
                {
                    val = val.Replace("-", "");
                }
                if (val.Contains('.'))
                {
                    if (val.Length - val.IndexOf('.') - 1 != 1)
                    {
                        return false;
                    }
                }
                else
                {
                    if (!ImpIsNum(val))
                    {
                        return false;
                    }
                    if (val.Length > 3)
                    {
                        string strTemp = val.Substring(3, val.Length - 3);
                        char[] arrChar = strTemp.ToCharArray();
                        foreach (char c in arrChar)
                        {
                            if (c != '0')
                                return false;
                        }
                    }
                }


                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }





        /// <summary>
        /// 两位有效数字，小数不过3位
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static bool isRightFormatTwoThree(string val)
        {

            try
            {
                if (val.Contains('-'))
                {
                    val = val.Replace("-", "");
                }
                if (val.Contains('.'))
                {
                    decimal decVal = Convert.ToDecimal(val);
                    string interPart = val.Substring(0, val.IndexOf('.'));
                    if (interPart != "0")
                    {
                        if (val.Length != 3)
                            return false;
                    }
                    else
                    {
                        string strtemp = val.Substring(val.IndexOf('.') + 1, 1);
                        if (strtemp == "0")
                        {
                            if (val.Length != 5)
                                return false;
                        }
                        else
                        {
                            if (val.Length != 4)
                                return false;
                        }


                    }
                }
                else
                {
                    if (val.Length > 2)
                    {
                        string strTemp = val.Substring(2, val.Length - 2);
                        char[] arrChar = strTemp.ToCharArray();
                        foreach (char c in arrChar)
                        {
                            if (c != '0')
                                return false;
                        }
                    }
                }


                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        /// <summary>
        /// 是否为x.xx格式
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static bool isRightFormatSW(string val)
        {
            try
            {
                if (!isRightDigital(val))
                {
                    return false;
                }
                if (val.IndexOf(".") < 0)
                {
                    return false;
                }
                string strLength = val.Substring(val.IndexOf('.') + 1);

                //if (val.Length - val.IndexOf('.') - 1 != 2)
                if (strLength.Length != 2)
                {
                    return false;
                }
                decimal decVal = Convert.ToDecimal(val);

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        public static string formatBracket(string strLine)
        {
            strLine = strLine.Replace("\\", "");
            strLine = strLine.Replace("\\{", "");
            strLine = strLine.Replace("\\}", "");
            strLine = strLine.Replace("\\=", "");


            strLine = strLine.Replace("{", "");
            strLine = strLine.Replace("}", "");
            if (strLine.Contains("（"))
            {
                strLine = strLine.Replace("（", "(");
            }
            if (strLine.Contains("）"))
            {
                strLine = strLine.Replace("）", ")");
            }
            return strLine;
        }
        public static string removeAdditionBracket(string strLine)
        {
            if (strLine.Contains("（"))
            {
                strLine = strLine.Replace("（", "(");
            }
            if (strLine.Contains("）"))
            {
                strLine = strLine.Replace("）", ")");
            }

            if (strLine.Contains("(   "))
            {
                strLine = strLine.Replace("(   ", "(");
            }
            if (strLine.Contains("(  "))
            {
                strLine = strLine.Replace("(  ", "(");
            }

            if (strLine.Contains("( "))
            {
                strLine = strLine.Replace("( ", "(");
            }
            if (strLine.Contains("    )"))
            {
                strLine = strLine.Replace("    )", ")");
            }
            if (strLine.Contains("   )"))
            {
                strLine = strLine.Replace("   )", ")");
            }
            if (strLine.Contains("  )"))
            {
                strLine = strLine.Replace("  )", ")");
            }
            if (strLine.Contains(" )"))
            {
                strLine = strLine.Replace(" ) ", ")");
            }
            if (strLine.Contains("( "))
            {
                strLine = strLine.Replace("( ", "(");
            }
            if (strLine.Contains(" )"))
            {
                strLine = strLine.Replace(" )", ")");
            }
            if (strLine.Contains("("))
            {
                strLine = strLine.Replace("(", "");
            }
            if (strLine.Contains(")"))
            {
                strLine = strLine.Replace(")", "");
            }
            return strLine;
        }


        /// <summary>
        /// 是否为x.x格式,1位小数
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static bool isRightFormatSW1(string val)
        {
            try
            {
                val = removeAdditionBracket(val);
                if (!isRightDigital(val))
                {
                    return false;
                }
                if (val.Length < 3)
                {
                    return false;
                }
                string strLength = val.Substring(val.IndexOf('.') + 1);
                decimal decVal = Convert.ToDecimal(val);
                //if (val.Length - val.IndexOf('.') - 1 != 2)
                if (strLength.Length != 1)
                {
                    return false;
                }

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        /// <summary>
        /// 流速，冰速，底速 不小于1m/s，取三位有效数字；小于1m/s时，取两位有效数字，小数不过三位
        /// </summary>
        /// <param name="strVal"></param>
        /// <returns></returns>
        public static bool isRightFormatLS(string strVal)
        {
            try
            {
                decimal dVal = Convert.ToDecimal(strVal);
                if (dVal >= 1)
                {
                    return isRightFormatMonthQAT(strVal);

                }
                else
                {
                    return isRightFormatTwoThree(strVal);
                }
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        /// <summary>
        /// 得到一个月中有多少天数
        /// </summary>
        /// <param name="isRunYear"></param>
        /// <param name="month"></param>
        /// <returns></returns>
        public static int getMonthDays(bool isRunYear, int month)
        {
            int monthdays = 31;
            if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
            {
                monthdays = 31;
            }
            if (month == 4 || month == 6 || month == 9 || month == 11)
            {
                monthdays = 30;
            }
            if (month == 2)
            {
                if (isRunYear)
                    monthdays = 29;
                else
                    monthdays = 28;
            }
            return monthdays;
        }
        /// <summary>
        /// 判断时间是否合法
        /// </summary>
        /// <param name="StrSource"></param>
        /// <returns></returns>
        public static bool IsTime(string StrSource)
        {
            try
            {
                if(StrSource.StartsWith("0000"))
                {
                    return false;
                }
                if (StrSource.Contains(":"))
                {
                    string[] arrTime = StrSource.Trim().Split(':');
                    if (arrTime.Length != 2)
                    {
                        return false;
                    }
                    if (!ImpIsNum(arrTime[0]) || !ImpIsNum(arrTime[1]))
                    {
                        return false;
                    }
                    int hour = Convert.ToInt32(arrTime[0]);
                    int minute = Convert.ToInt32(arrTime[1]);
                    if (hour > 24 || minute >= 60)
                    {
                        return false;
                    }
                    if (hour == 24)
                    {
                        if (minute > 0)
                        {
                            return false;
                        }
                    }
                    return true;
                }
                else
                {
                    if (!ImpIsNum(StrSource))
                    {
                        return false;
                    }
                    int hour = Convert.ToInt32(StrSource);
                    if (hour > 24)
                    {
                        return false;
                    }
                    return true;
                }

            }
            catch (Exception ex)
            {
            }
            return false;
        }
        /// <summary>
        /// 水面宽度 取，不小三位有效数字于5m，小数不过1位；小于5m，小数不过两位
        /// </summary>
        /// <param name="strVal"></param>
        /// <returns></returns>
        public static bool isRiverWidthRight(string strVal)
        {
            try
            {
                decimal dVal = Convert.ToDecimal(strVal);
                if (dVal >= 5)
                {
                    if (!isRightFormatWidth(strVal))
                        return false;
                }
                else
                {
                    if (!isRightFormatSquare(strVal))
                        return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        /// <summary>
        /// 水深 取三位有效数字，不小于5m，小数不过1位；小于5m，小数不过两位
        /// </summary>
        /// <param name="strVal"></param>
        /// <returns></returns>
        public static bool isRiverheightRight(string strVal)
        {
            try
            {
                decimal dVal = Convert.ToDecimal(strVal);
                if (dVal >= 5 && dVal < 100)
                {
                    if (strVal.IndexOf('.') <= 0)
                        return false;
                    if (strVal.Length - strVal.IndexOf('.') - 1 != 1)
                        return false;
                }
                if (dVal < 5)
                {
                    if (strVal.IndexOf('.') <= 0)
                        return false;
                    if (strVal.Length - strVal.IndexOf('.') - 1 != 2)
                        return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }


        /// <summary>
        /// 水深 取三位有效数字，不小于5m，小数不过1位；小于5m，小数不过两位
        /// </summary>
        /// <param name="strVal"></param>
        /// <returns></returns>
        public static string getRiverheightRight(string strVal)
        {
            string strResult = strVal;
            try
            {
                decimal dVal = Convert.ToDecimal(strVal);
                if (dVal >= 100)
                {
                    strResult = getInterigitOnly(strVal);
                }
                if (dVal >= 5 && dVal < 100)
                {
                    strResult = getDigitPATOnly(strVal);
                }
                if (dVal < 5)
                {
                    strResult = getDigitTwoDigitOnly(strVal);
                }
                return strResult;
            }
            catch (Exception ex)
            {
                return strResult;
            }
        }


        /// <summary>
        /// 检测降雨量摘录表开始时间和结束时间间隔是否跨8点和20点
        /// </summary>
        /// <param name="hourStart"></param>
        /// <param name="hourEnd"></param>
        /// <returns></returns>
        public static bool IsTimeSpanRight(int hourStart, int hourEnd)
        {

            if (hourStart < 8 && hourEnd > 8)
            {
                return false;
            }
            if (hourStart < 20 && hourEnd > 20)
            {
                return false;
            }
            return true;
        }

        /// <summary>
        /// 判断日期是否合法
        /// </summary>
        /// <param name="isRunYear"></param>
        /// <param name="month"></param>
        /// <param name="day"></param>
        /// <returns></returns>
        public static bool IsMonthDayMatch(bool isRunYear, string month, string day)
        {
            try
            {
                int monthDays = 31;
                int conMonth = Convert.ToInt32(month);
                int conday = Convert.ToInt32(day);
                if (conMonth < 1 || conMonth > 12)
                {
                    return false;
                }
                if (conMonth == 2)
                {
                    if (isRunYear)
                    {
                        monthDays = 29;
                    }
                    else
                    {
                        monthDays = 28;
                    }
                }
                if (conMonth == 4 || conMonth == 6 || conMonth == 9 || conMonth == 11)
                {
                    monthDays = 30;
                }
                if (conMonth == 1 || conMonth == 3 || conMonth == 5 || conMonth == 7 || conMonth == 8 || conMonth == 10 || conMonth == 12)
                {
                    monthDays = 31;
                }
                if (conday < 1 || conday > monthDays)
                {
                    return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }


        public static string getSquareCoverResult(ArrayList arList)
        {
            string result = string.Empty;
            try
            {
                int index = 0;
                bool bcontainValue = false;
                bool bcontainDesc = false;
                string riverDesc = string.Empty;
                //arList.Count
                string[] arrTime = new string[arList.Count];
                string[] arrVal = new string[arList.Count];

                foreach (string strList in arList)
                {
                    string[] ar = strList.Trim().Split(' ');

                    if (ar.Length < 2)
                    {
                        return string.Empty;
                    }
                    string curtime = ar[0];
                    if (!IsTime(ar[0]))
                    {
                        return string.Empty;
                    }
                    if (ar[0].Contains(":"))
                    {
                        string strPart = ar[0].Substring(ar[0].IndexOf(":") + 1);
                        string intPart = ar[0].Substring(0, ar[0].IndexOf(":"));
                        decimal decmimalPart = Convert.ToDecimal(strPart) / 60;
                        decmimalPart = convertValue(decmimalPart.ToString(), 2);
                        curtime = (Convert.ToDecimal(intPart) + decmimalPart).ToString();

                    }
                    if (ar[1].Contains("干") || ar[1].Contains("冻"))
                    {
                        bcontainDesc = true;
                        riverDesc = ar[1];
                    }
                    else
                    {
                        bcontainValue = true;
                        arrTime[index] = curtime;
                        arrVal[index] = ar[1];
                    }
                    if (bcontainDesc)
                    {
                        index++;
                        continue;
                    }

                    index++;
                }
                if (bcontainDesc)
                {
                    if (bcontainValue)
                    {
                        return "部分" + riverDesc;
                    }
                    else
                    {
                        return riverDesc;
                    }
                }
                decimal sum = 0;
                for (int m = 0; m < arrTime.Length; m++)
                {
                    if (m == 0 && arrTime.Length > 1)
                    {
                        sum = Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m]));
                        continue;
                    }
                    if (m == arrTime.Length - 1)
                    {
                        sum = sum + Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                        break;
                    }
                    sum = sum + Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m])
                        + Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                }
                decimal averageVal = sum / 48;
                return averageVal.ToString();

            }
            catch (Exception ex)
            {
                return result;
            }
        }

        public static string getTimeDigit(string strTimeVal)
        {
            string curtime = strTimeVal;
            try
            {
                if (strTimeVal.Contains(":"))
                {
                    string strPart = strTimeVal.Substring(strTimeVal.IndexOf(":") + 1);
                    string intPart = strTimeVal.Substring(0, strTimeVal.IndexOf(":"));
                    decimal decmimalPart = Convert.ToDecimal(strPart) / 60;
                    decmimalPart = convertValue(decmimalPart.ToString(), 2);
                    curtime = (Convert.ToDecimal(intPart) + decmimalPart).ToString();
                }
            }
            catch (Exception ex)
            {
            }
            return curtime;
        }
        public static string getSquareCoverResultQQT(ArrayList arList)
        {
            string result = string.Empty;
            try
            {
                int index = 0;
                bool bcontainValue = false;
                bool bcontainDesc = false;
                string riverDesc = string.Empty;
                //arList.Count
                string[] arrTime = new string[arList.Count];
                string[] arrVal = new string[arList.Count];
                foreach (string strList in arList)
                {
                    string[] ar = strList.Trim().Split(' ');

                    if (ar.Length < 2)
                    {
                        return string.Empty;
                    }
                    if (ar[1] == "$")
                    {
                        return "$";
                    }
                }
                foreach (string strList in arList)
                {
                    string[] ar = strList.Trim().Split(' ');

                    if (ar.Length < 2)
                    {
                        return string.Empty;
                    }
                    string curtime = ar[0];
                    if (!IsTime(ar[0]))
                    {
                        return string.Empty;
                    }
                    if (ar[0].Contains(":"))
                    {
                        string strPart = ar[0].Substring(ar[0].IndexOf(":") + 1);
                        string intPart = ar[0].Substring(0, ar[0].IndexOf(":"));
                        decimal decmimalPart = Convert.ToDecimal(strPart) / 60;
                        decmimalPart = convertValue(decmimalPart.ToString(), 2);
                        curtime = (Convert.ToDecimal(intPart) + decmimalPart).ToString();

                    }
                    if (ar[1].Contains("干") || ar[1].Contains("冻"))
                    {
                        bcontainDesc = true;
                        riverDesc = ar[1];
                    }
                    else
                    {
                        bcontainValue = true;
                        arrTime[index] = curtime;
                        arrVal[index] = ar[1];
                    }
                    if (bcontainDesc)
                    {
                        index++;
                        continue;
                    }

                    index++;
                }
                if (bcontainDesc)
                {
                    if (bcontainValue)
                    {
                        return "部分" + riverDesc;
                    }
                    else
                    {
                        return riverDesc;
                    }
                }
                decimal sum = 0;
                for (int m = 0; m < arrTime.Length; m++)
                {
                    if (m == 0 && arrTime.Length > 1)
                    {
                        sum = Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m]));
                        continue;
                    }
                    if (m == arrTime.Length - 1)
                    {
                        sum = sum + Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                        break;
                    }
                    sum = sum + Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m])
                        + Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                }
                decimal averageVal = sum / 48;
                return averageVal.ToString();

            }
            catch (Exception ex)
            {
                return result;
            }
        }
        public static string getSquareCoverResultLL(ArrayList arList)
        {
            string result = string.Empty;
            try
            {
                int index = 0;
                bool bcontainValue = false;
                bool bcontainDesc = false;
                string riverDesc = string.Empty;
                //arList.Count
                string[] arrTime = new string[arList.Count];
                string[] arrVal = new string[arList.Count];

                foreach (string strList in arList)
                {
                    string[] ar = strList.Trim().Split(' ');

                    if (ar.Length < 3)
                    {
                        return string.Empty;
                    }
                    string curtime = ar[0];
                    if (!IsTime(ar[0]))
                    {
                        return string.Empty;
                    }
                    if (ar[0].Contains(":"))
                    {
                        string strPart = ar[0].Substring(ar[0].IndexOf(":") + 1);
                        string intPart = ar[0].Substring(0, ar[0].IndexOf(":"));
                        decimal decmimalPart = Convert.ToDecimal(strPart) / 60;
                        decmimalPart = convertValue(decmimalPart.ToString(), 2);
                        curtime = (Convert.ToDecimal(intPart) + decmimalPart).ToString();

                    }
                    if (ar[3].Contains("干") || ar[3].Contains("冻"))
                    {
                        bcontainDesc = true;
                        riverDesc = ar[3];
                    }
                    else
                    {
                        bcontainValue = true;
                        arrTime[index] = curtime;
                        arrVal[index] = ar[3];
                    }
                    if (bcontainDesc)
                    {
                        index++;
                        continue;
                    }

                    index++;
                }
                if (bcontainDesc)
                {
                    if (bcontainValue)
                    {
                        return "部分" + riverDesc;
                    }
                    else
                    {
                        return riverDesc;
                    }
                }
                decimal sum = 0;
                for (int m = 0; m < arrTime.Length; m++)
                {
                    if (m == 0 && arrTime.Length > 1)
                    {
                        sum = Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m]));
                        continue;
                    }
                    if (m == arrTime.Length - 1)
                    {
                        sum = sum + Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                        break;
                    }
                    sum = sum + Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m])
                        + Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                }
                decimal averageVal = sum / 48;
                return averageVal.ToString();

            }
            catch (Exception ex)
            {
                return result;
            }
        }

        public static string getSquareCoverResultSWLL(ArrayList arList)
        {
            string result = string.Empty;
            try
            {
                int index = 0;
                bool bcontainValue = false;
                bool bcontainDesc = false;
                bool bContainEmpty = false;
                string riverDesc = string.Empty;
                //arList.Count
                string[] arrTime = new string[arList.Count];
                string[] arrVal = new string[arList.Count];
                string[] arrValLL = new string[arList.Count];
                string compuredSW = string.Empty;
                string compuredLL = string.Empty;
                foreach (string strList in arList)
                {
                    string[] ar = strList.Trim().Split(' ');

                    if (ar.Length < 3)
                    {
                        return string.Empty;
                    }
                    string curtime = ar[0];
                    if (!IsTime(ar[0]))
                    {
                        return string.Empty;
                    }
                    if (ar[0].Contains(":"))
                    {
                        string strPart = ar[0].Substring(ar[0].IndexOf(":") + 1);
                        string intPart = ar[0].Substring(0, ar[0].IndexOf(":"));
                        decimal decmimalPart = Convert.ToDecimal(strPart) / 60;
                        decmimalPart = convertValue(decmimalPart.ToString(), 2);
                        curtime = (Convert.ToDecimal(intPart) + decmimalPart).ToString();

                    }
                    arrTime[index] = curtime;
                    if (ar[1].Contains("干") || ar[1].Contains("冻"))
                    {
                        bcontainDesc = true;
                        riverDesc = ar[1];
                    }
                    else
                    {
                        bcontainValue = true;
                        arrVal[index] = ar[1];
                    }

                    if (ar[2] == "$")
                    {
                        bContainEmpty = true;
                    }
                    arrValLL[index] = ar[2];

                    index++;
                }
                if (bcontainDesc)
                {
                    if (bcontainValue)
                    {
                        compuredSW = "部分" + riverDesc;
                    }
                    else
                    {
                        compuredSW = riverDesc;
                    }
                }
                if (bContainEmpty)
                {
                    compuredLL = "$";
                }
                if (!bcontainDesc)
                {
                    decimal sum = 0;
                    for (int m = 0; m < arrTime.Length; m++)
                    {
                        if (m == 0 && arrTime.Length > 1)
                        {
                            sum = Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m]));
                            continue;
                        }
                        if (m == arrTime.Length - 1)
                        {
                            sum = sum + Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                            break;
                        }
                        sum = sum + Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m])
                            + Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                    }
                    decimal averageVal = sum / 48;
                    compuredSW = averageVal.ToString();
                }

                if (!bContainEmpty)
                {
                    decimal sum = 0;
                    for (int m = 0; m < arrTime.Length; m++)
                    {
                        if (m == 0 && arrTime.Length > 1)
                        {
                            sum = Convert.ToDecimal(arrValLL[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m]));
                            continue;
                        }
                        if (m == arrTime.Length - 1)
                        {
                            sum = sum + Convert.ToDecimal(arrValLL[m]) * (Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                            break;
                        }
                        sum = sum + Convert.ToDecimal(arrValLL[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m])
                            + Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                    }
                    decimal averageVal = sum / 48;
                    compuredLL = averageVal.ToString();
                }

                result = compuredSW + " " + compuredLL;
                return result;


            }
            catch (Exception ex)
            {
                return "$" + " " + "$";
            }
        }

        public static string getSquareCoverResultSWLL(ArrayList arList, string strHashKey)
        {
            string result = string.Empty;
            try
            {
                int index = 0;
                bool bcontainValue = false;
                bool bcontainDesc = false;
                bool bContainEmpty = false;
                string riverDesc = string.Empty;
                //arList.Count
                string[] arrTime = new string[arList.Count];
                string[] arrVal = new string[arList.Count];
                string[] arrValLL = new string[arList.Count];
                string compuredSW = string.Empty;
                string compuredLL = string.Empty;
                foreach (string strList in arList)
                {
                    string[] ar = strList.Trim().Split(' ');

                    if (ar.Length < 3)
                    {
                        return string.Empty;
                    }
                    string curtime = ar[0];
                    if (!IsTime(ar[0]))
                    {
                        return string.Empty;
                    }
                    if (ar[0].Contains(":"))
                    {
                        string strPart = ar[0].Substring(ar[0].IndexOf(":") + 1);
                        string intPart = ar[0].Substring(0, ar[0].IndexOf(":"));
                        decimal decmimalPart = Convert.ToDecimal(strPart) / 60;
                        decmimalPart = convertValue(decmimalPart.ToString(), 2);
                        curtime = (Convert.ToDecimal(intPart) + decmimalPart).ToString();

                    }
                    arrTime[index] = curtime;
                    string strSW = string.Empty;
                    if (strHashKey.Contains("闸下"))
                    {
                        strSW = ar[2];

                    }
                    else
                    {
                        strSW = ar[1];
                    }
                    if (strSW.Contains("干") || strSW.Contains("冻"))
                    {
                        bcontainDesc = true;
                        riverDesc = strSW;
                    }
                    else
                    {
                        bcontainValue = true;
                        arrVal[index] = strSW;
                    }

                    if (ar[3] == "$")
                    {
                        bContainEmpty = true;
                        arrValLL[index] = "0";
                    }
                    else
                    {
                        arrValLL[index] = ar[3];
                    }

                    index++;
                }
                if (bcontainDesc)
                {
                    if (bcontainValue)
                    {
                        compuredSW = "部分" + riverDesc;
                    }
                    else
                    {
                        compuredSW = riverDesc;
                    }
                }
                if (bContainEmpty)
                {
                    compuredLL = "$";
                }
                if (!bcontainDesc)
                {
                    decimal sum = 0;
                    for (int m = 0; m < arrTime.Length; m++)
                    {
                        if (m == 0 && arrTime.Length > 1)
                        {
                            sum = Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m]));
                            continue;
                        }
                        if (m == arrTime.Length - 1)
                        {
                            sum = sum + Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                            break;
                        }
                        sum = sum + Convert.ToDecimal(arrVal[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m])
                            + Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                    }
                    decimal averageVal = sum / 48;
                    compuredSW = averageVal.ToString();
                }

                //if (!bContainEmpty)
                {
                    decimal sum = 0;
                    for (int m = 0; m < arrTime.Length; m++)
                    {
                        if (m == 0 && arrTime.Length > 1)
                        {
                            sum = Convert.ToDecimal(arrValLL[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m]));
                            continue;
                        }
                        if (m == arrTime.Length - 1)
                        {
                            sum = sum + Convert.ToDecimal(arrValLL[m]) * (Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                            break;
                        }
                        sum = sum + Convert.ToDecimal(arrValLL[m]) * (Convert.ToDecimal(arrTime[m + 1]) - Convert.ToDecimal(arrTime[m])
                            + Convert.ToDecimal(arrTime[m]) - Convert.ToDecimal(arrTime[m - 1]));
                    }
                    decimal averageVal = sum / 48;
                    compuredLL = averageVal.ToString();
                }

                result = compuredSW + " " + compuredLL;
                return result;


            }
            catch (Exception ex)
            {
                return "$" + " " + "$";
            }
        }

        public static string getPriorKey(bool isRunYear, string key)
        {
            string priorKey = string.Empty;
            string[] ar = key.Trim().Split('-');
            string curDay = string.Empty;
            string curMonth = string.Empty;
            if (ar.Length > 1)
            {
                curDay = ar[1];
                curMonth = ar[0];
            }
            else
            {
                return string.Empty;
            }
            try
            {
                if (Convert.ToInt32(curDay) >= 2)
                {
                    int priorDay = Convert.ToInt32(curDay) - 1;
                    priorKey = curMonth + "-" + priorDay.ToString();
                    return priorKey;
                }
                int priorDaykey = Convert.ToInt32(curDay) - 1;
                if (!IsMonthDayMatch(isRunYear, curMonth, priorDaykey.ToString()))
                {
                    if (curMonth != "1")
                    {
                        int days = getMonthDays(isRunYear, Convert.ToInt32(curMonth) - 1);
                        priorKey = (Convert.ToInt32(curMonth) - 1).ToString() + "-" + days.ToString();
                    }
                }
                else
                {
                    priorKey = curMonth + "-" + priorDaykey.ToString();
                }
                return priorKey;
            }
            catch (Exception ex)
            {
                return string.Empty;
            }


        }

        public static string getNextKey(bool isRunYear, string key)
        {
            string nextKey = string.Empty;
            string[] ar = key.Trim().Split('-');
            string curDay = string.Empty;
            string curMonth = string.Empty;
            if (ar.Length > 1)
            {
                curDay = ar[1];
                curMonth = ar[0];
            }
            else
            {
                return string.Empty;
            }
            try
            {
                if (Convert.ToInt32(curDay) <= 27)
                {
                    int nextDay = Convert.ToInt32(curDay) + 1;
                    nextKey = curMonth + "-" + nextDay.ToString();
                    return nextKey;
                }
                int nextDaykey = Convert.ToInt32(curDay) + 1;
                if (!IsMonthDayMatch(isRunYear, curMonth, nextDaykey.ToString()))
                {
                    if (curMonth != "12")
                    {
                        nextKey = (Convert.ToInt32(curMonth) + 1).ToString() + "-" + "1";
                    }
                }
                else
                {
                    nextKey = curMonth + "-" + nextDaykey.ToString();
                }
                return nextKey;
            }
            catch (Exception ex)
            {
                return string.Empty;
            }


        }
        /// <summary>
        /// 比较两个日期大小eg 7-12  6-19，如果Date1 > Date2 ，返回"1"，小于则返回"-1",相等则返回"0"
        /// </summary>
        /// <param name="strDate1"></param>
        /// <param name="strDate2"></param>
        /// <returns></returns>
        public static string compareTwoDateTime(string strDate1, string strDate2)
        {
            try
            {
                if (strDate1.Contains("-") && strDate2.Contains("-"))
                {
                    string[] arrDate1 = strDate1.Trim().Split('-');
                    string[] arrDate2 = strDate2.Trim().Split('-');
                    if (arrDate1.Length != 2 && arrDate2.Length != 2)
                    {
                        return string.Empty;
                    }
                    int iDateMonth1 = Convert.ToInt32(arrDate1[0]);
                    int iDateMonth2 = Convert.ToInt32(arrDate2[0]);
                    int iDateDay1 = Convert.ToInt32(arrDate1[1]);
                    int iDateDay2 = Convert.ToInt32(arrDate2[1]);
                    if (iDateMonth1 > iDateMonth2)
                    {
                        return "1";
                    }
                    if (iDateMonth1 < iDateMonth2)
                    {
                        return "-1";
                    }
                    if (iDateMonth1 == iDateMonth2)
                    {
                        if (iDateDay1 > iDateDay2)
                        {
                            return "1";
                        }
                        if (iDateDay1 < iDateDay2)
                        {
                            return "-1";
                        }
                        if (iDateDay1 == iDateDay2)
                        {
                            return "0";
                        }
                    }
                    return "1";
                }
                else
                {
                    return string.Empty;
                }
            }
            catch (Exception ex)
            {
                return string.Empty;
            }
        }

        /// <summary>
        /// 去除特殊符号，只得到数字
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public static string getDigitOnly(string val)
        {
            string strReturn = string.Empty;
            if (val.Trim().Length < 1)
            {
                return strReturn;
            }
            char[] arr = val.ToCharArray();
            int index = 0;
            foreach (char c in arr)
            {
                if (c == '.' || ImpIsNum(c.ToString()))
                {
                    strReturn = strReturn + c;
                }
                if (index == 0 && c == '-')
                {
                    strReturn = strReturn + c;
                }
                index++;
            }
            return strReturn;
        }

        public static bool isRightDigital(string val)
        {
            if (val == string.Empty || val == "" || val == null)
            {
                return false;
            }
            if (val.EndsWith("."))
            {
                return false;
            }
            string strVal = val.Replace(".", "");
            if (strVal.Contains("-"))
            {
                if (!strVal.StartsWith("-"))
                {
                    return false;
                }
            }
            strVal = strVal.Replace("-", "");

            if (ImpIsNum(strVal))
                return true;
            else
                return false;
        }

        public static string getZeroHourVal(string t1, string t2, string val1, string val2)
        {
            decimal time1 = 0;
            decimal time2 = 0;
            try
            {
                if (t1.Contains(":"))
                {
                    string strPart = t1.Substring(t1.IndexOf(":") + 1);
                    string intPart = t1.Substring(0, t1.IndexOf(":"));
                    decimal decmimalPart = Convert.ToDecimal(strPart) / 60;

                    decmimalPart = MathUtility.convertValue(decmimalPart.ToString(), 2);

                    t1 = (Convert.ToDecimal(intPart) + decmimalPart).ToString();
                }
                if (t2.Contains(":"))
                {
                    string strPart = t2.Substring(t2.IndexOf(":") + 1);
                    string intPart = t2.Substring(0, t2.IndexOf(":"));
                    decimal decmimalPart = Convert.ToDecimal(strPart) / 60;

                    decmimalPart = MathUtility.convertValue(decmimalPart.ToString(), 2);
                    t2 = (Convert.ToDecimal(intPart) + decmimalPart).ToString();
                }

                time1 = Convert.ToDecimal(t1);
                time2 = Convert.ToDecimal(t2);
                decimal span = time2 + 24 - time1;
                //if (val1.Contains("干") || val1.Contains("冻") || val1.Contains("$"))
                //    return val1;
                //if (val2.Contains("干") || val2.Contains("冻") || val2.Contains("$"))
                //    return val2;
                if (val1.Contains("干") || val1.Contains("冻") || val1.Contains("$"))
                    val1 = "0";
                if (val2.Contains("干") || val2.Contains("冻") || val2.Contains("$"))
                    val2 = "0";
                decimal sub = Convert.ToDecimal(val2) - Convert.ToDecimal(val1);
                decimal result = Convert.ToDecimal(val1) + (sub / span) * (24 - time1);
                return result.ToString();
            }
            catch (Exception ex)
            {
                return string.Empty;
            }
        }
        //去掉特殊符合
        public static string getConvVAl(string strVal)
        {
            string conValue = strVal;
            if (strVal.Length > 0)
            {
                if (strVal.Contains('A'))
                {
                    conValue = strVal.Replace("A", "");
                    return conValue;
                }
                if (strVal.Contains('B'))
                {
                    conValue = strVal.Replace("B", "");
                    return conValue;
                }
                if (strVal.Contains("G%"))
                {
                    conValue = strVal.Replace("G%", "");
                    return conValue;

                }
                if (strVal.Contains("L%"))
                {
                    conValue = strVal.Replace("L%", "");
                    return conValue;

                }
                if (strVal.Contains('G'))
                {
                    conValue = strVal.Replace("G", "");
                    return conValue;

                }
                if (strVal.Contains('L'))
                {
                    conValue = strVal.Replace("L", "");
                    return conValue;
                }

            }
            return conValue;
        }

        public static string DeleteBraces(string strVal)
        {
            string strConv = string.Empty;
            strVal = strVal.Replace("（", "(");
            strVal = strVal.Replace("）", ")");

            strConv = strVal;
            if (strVal.Contains("(") || strVal.Contains(")"))
            {
                strConv = strVal.Replace("(", "");
                strConv = strConv.Replace(")", "");
            }
            return strConv;
        }
        public static string[] DeleteBraces(string[] arrLine)
        {
            for (int i = 0; i < arrLine.Length; i++)
            {
                if (arrLine[i].Contains("(") || arrLine[i].Contains(")"))
                {
                    arrLine[i] = arrLine[i].Replace("(", "");
                    arrLine[i] = arrLine[i].Replace(")", "");
                }
            }
            return arrLine;
        }

        public static bool IsNatural_Number(string str)
        {
            System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[A-Za-z0-9]+$");
            return reg1.IsMatch(str);
        }
        /// <summary>
        /// 检查行数是否遗漏
        /// </summary>
        /// <param name="ar"></param>
        /// <param name="rowNumbers"></param>
        /// <param name="columnNumbers"></param>
        /// <returns></returns>
        public static bool getLinesCount(ArrayList ar, int rowNumbers, int columnNumbers, int adRowNumber, int adColumnNumbers)
        {
            try
            {
                if (ar != null)
                {
                    if (ar.Count >= adRowNumber)
                    {
                        string strLine = ar[rowNumbers - 1] as string;
                        string[] arrLines = strLine.Trim().Trim().Split(' ');
                        string strAdLine = ar[adRowNumber - 1] as string;
                        string[] arrAdLines = strAdLine.Trim().Trim().Split(' ');
                        if (arrLines.Length != columnNumbers || arrAdLines.Length != adColumnNumbers)
                        {
                            return false;
                        }
                        else
                        {
                            return true;
                        }
                    }
                }
                return false;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 返回站点描述，是河，渠，库
        /// </summary>
        /// <param name="riverName"></param>
        /// <returns></returns>
        public static string getRiverOrOtherDesc(string riverName, string stationName)
        {
            if (stationName.Contains("水库") && stationName.Contains("渠"))
            {
                if (stationName.LastIndexOf("渠") > stationName.LastIndexOf("水库"))
                {
                    return "渠干";
                }
            }
            if (stationName.Contains("水库"))
            {
                return "库干";
            }
            if (stationName.Contains("渠"))
            {
                return "渠干";
            }
            if (riverName.Contains("河"))
            {
                return "河干";
            }
            if (riverName.Contains("渠"))
            {
                return "渠干";
            }

            return "河干";
        }

        public static string getDumpErrorInfo(string strErrorInfo)
        {

            if (strErrorInfo.Contains("数据为空") && m_errorInfo.Contains("数据为空"))
            {
                string strEndDate = strErrorInfo.Substring(strErrorInfo.IndexOf("站") + 1, strErrorInfo.IndexOf("日") + 1 - strErrorInfo.IndexOf("站"));
                string strErrorEndDate = m_errorInfo.Substring(m_errorInfo.LastIndexOf("月") - 2, m_errorInfo.LastIndexOf("日") + 1 - m_errorInfo.LastIndexOf("月"));
                if (strEndDate.Contains("月") && strEndDate.Contains("日") && strErrorEndDate.Contains("月") && strErrorEndDate.Contains("日"))
                {
                    string endDate = strEndDate.Substring(strEndDate.IndexOf("月") + 1, strEndDate.IndexOf("日") - strEndDate.IndexOf("月") - 1);
                    string endDateError = strErrorEndDate.Substring(strErrorEndDate.IndexOf("月") + 1, strErrorEndDate.IndexOf("日") - strErrorEndDate.IndexOf("月") - 1);
                    endDate = endDate.Replace(" ", "");
                    endDateError = endDateError.Replace(" ", "");
                    if (ImpIsNum(endDate) && ImpIsNum(endDateError))
                    {
                        if (Convert.ToInt32(endDate) - Convert.ToInt32(endDateError) == 1)
                        {
                            if (!m_errorInfo.Contains("至"))
                            {
                                m_errorInfo = m_errorInfo.Insert(m_errorInfo.IndexOf("日") + 1, "至" + strEndDate);
                            }
                            else
                            {
                                m_errorInfo = m_errorInfo.Replace(strErrorEndDate, strEndDate);
                            }
                            return string.Empty;
                        }
                        else
                        {
                            string val = m_errorInfo + "&" + strErrorInfo;
                            m_errorInfo = string.Empty;
                            return val;
                        }

                    }
                    else
                    {
                        string val = m_errorInfo + "&" + strErrorInfo;
                        m_errorInfo = string.Empty;
                        return val;
                    }

                }
                else
                {
                    return string.Empty;
                }
            }
            else if (strErrorInfo.Contains("数据为空") && m_errorInfo == string.Empty)
            {
                m_errorInfo = strErrorInfo;
                return string.Empty;
            }
            return string.Empty;
        }

        public static string getDigitPATOnly(string strVal)
        {
            string result = strVal;
            try
            {
                if (strVal.Contains("."))
                {
                    result = strVal.Substring(0, strVal.IndexOf('.') + 2);
                }
            }
            catch (Exception)
            {
            }
            return result;
        }
        /// <summary>
        /// 记至0.01m
        /// </summary>
        /// <param name="strVal"></param>
        /// <returns></returns>
        public static string getDigitTwoDigitOnly(string strVal)
        {
            string result = strVal;
            try
            {
                if (strVal.Contains("."))
                {
                    result = strVal.Substring(0, strVal.IndexOf('.') + 3);
                }
            }
            catch (Exception)
            {
            }
            return result;
        }

        /// <summary>
        /// 记至1m
        /// </summary>
        /// <param name="strVal"></param>
        /// <returns></returns>
        public static string getInterigitOnly(string strVal)
        {
            string result = strVal;
            try
            {
                if (strVal.Contains("."))
                {
                    result = strVal.Substring(0, strVal.IndexOf('.'));
                }
            }
            catch (Exception)
            {
            }
            return result;
        }

        public static bool isDateInReport(string date)
        {
            string month = date.Substring(0, date.IndexOf('-'));
            string day = date.Substring(date.IndexOf('-') + 1);
            if (MathUtility.ImpIsNum(month) && MathUtility.ImpIsNum(day))
            {
                if (Convert.ToInt32(month) < 6 || Convert.ToInt32(month) > 9)
                {
                    return false;
                }
            }
            return true;
        }


        public static string getQQTName(string strQQTFullName)
        {
            string strResult = strQQTFullName;
            if (strQQTFullName.Contains("水库"))
            {
                strResult = strQQTFullName.Substring(0, strQQTFullName.LastIndexOf("水库") + 2);
            }
            return strResult;
        }

        /// <summary>
        /// 判断是否包含括号
        /// </summary>
        /// <param name="strVal"></param>
        /// <returns></returns>
        public static bool isContainsBrackers(string strVal)
        {
            if ((strVal.Contains("(") || strVal.Contains("（")) && (strVal.Contains(")") || strVal.Contains("）")))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public static string getYearFromFileName(string strFileName)
        {
            string strYear = "";
            try
            {
                if (strFileName.Contains("\\"))
                {
                    strFileName = strFileName.Substring(strFileName.LastIndexOf("\\") + 1);
                }
                if (strFileName.Length > 10)
                {
                    strYear = strFileName.Substring(6, 4);
                }
                return strYear;

            }
            catch (Exception ex)
            {
                return strYear;
            }
        }

        public static bool isAllEmpty(string[] arr)
        {
            bool res = true;
            if (arr == null)
            {
                return true;
            }
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i].Trim() != "$")
                {
                    res = false;
                }
            }
            return res;
        }

        public static bool isContainDigit(string text)

        {
            for (int i = 0; i < text.Length; i++)
            {
                if (text[i] >= 48 && text[i] <= 57)
                {
                    return true;
                }
            }
            return false;
        }

        public static string getMonthByStr(string strMonVal)
        {
            string strMonth = "";
            if (strMonVal == "一月")
            {
                strMonth = "01";
            }
            if (strMonVal == "二月")
            {
                strMonth = "02";
            }
            if (strMonVal == "三月")
            {
                strMonth = "03";
            }
            if (strMonVal == "四月")
            {
                strMonth = "04";
            }
            if (strMonVal == "五月")
            {
                strMonth = "05";
            }
            if (strMonVal == "六月")
            {
                strMonth = "06";
            }
            if (strMonVal == "七月")
            {
                strMonth = "07";
            }
            if (strMonVal == "八月")
            {
                strMonth = "08";
            }
            if (strMonVal == "九月")
            {
                strMonth = "09";
            }
            if (strMonVal == "十月")
            {
                strMonth = "10";
            }
            if (strMonVal == "十一月")
            {
                strMonth = "11";
            }
            if (strMonVal == "十二月")
            {
                strMonth = "12";
            }
            return strMonth;
        }

        /// <summary>
        /// 转换为标准写法 eg 1 为01
        /// </summary>
        /// <param name="strV"></param>
        /// <returns></returns>
        public static string getTwoDigitNum(string strV)
        {
            string strRes = strV;
            if (strV.Length == 1)
            {
                strRes = "0" + strV;
            }
            return strRes;

        }

        public static double ConvertDegreesToDigital(string degrees)
        {
            const double num = 60;
            double digitalDegree = 0.0;
            try
            {
                int d = degrees.IndexOf('°');
                if (d < 0)
                {
                    return digitalDegree;
                }
                string degree = degrees.Substring(0, d);
                digitalDegree += Convert.ToDouble(degree);

                int m = degrees.IndexOf('′');
                if (m < 0)
                {
                    return digitalDegree;
                }
                string minute = degrees.Substring(d + 1, m - d - 1);
                digitalDegree += ((Convert.ToDouble(minute)) / num);

                int s = degrees.IndexOf('″');
                if (s < 0)
                {
                    return digitalDegree;
                }
                string second = degrees.Substring(m + 1, s - m - 1);
                digitalDegree += (Convert.ToDouble(second) / (num * num));
            }
            catch (Exception ex)
            {

            }


            return digitalDegree;
        }


        public static string getTrimEndStr(string strInsert)
        {
            string strNewInsert = strInsert;
            try
            {
                if (strNewInsert.EndsWith(",,"))
                {
                    strNewInsert = strNewInsert.Substring(0, strNewInsert.Length - 1);
                }
                else
                {
                    strNewInsert = strNewInsert.TrimEnd(',');
                }

            }
            catch (Exception ex)
            {

            }
            return strNewInsert;
        }

        /// <summary>
        /// 获取造字的字符串
        /// </summary>
        /// <param name="strLine"></param>
        /// <returns></returns>
        public static string getZZStr(string strLine)
        {
            string strNewLine = strLine;
            try
            {

                if (strNewLine.Contains("\\{") && strNewLine.Contains("\\}") && (strNewLine.IndexOf("\\}") - strNewLine.IndexOf("\\{")) > 0)
                {
                    strNewLine = strNewLine.Replace("\\{", "");
                    strNewLine = strNewLine.Replace("\\}", "");
                }
                if (strNewLine.Contains("[SX(") && strNewLine.Contains("SX)]") && (strNewLine.IndexOf("SX)]") > strNewLine.IndexOf("[SX(")))
                {
                    string strSub = strNewLine.Substring(strNewLine.IndexOf("[SX("), strNewLine.IndexOf("SX)]") - strNewLine.IndexOf("[SX("));
                    string strNewSub = strSub.Replace("[]", "");
                    strNewLine = strNewLine.Replace(strSub, strNewSub);
                }
                if (strNewLine.Contains("[SX(") && strNewLine.Contains("SX)]") && (strNewLine.IndexOf("SX)]") > strNewLine.IndexOf("[SX(")))
                {
                    string strSub = strNewLine.Substring(strNewLine.IndexOf("[SX("), strNewLine.IndexOf("SX)]") - strNewLine.IndexOf("[SX("));
                    string strNewSub = strSub.Replace("[]", "");
                    strNewLine = strNewLine.Replace(strSub, strNewSub);
                }
            }
            catch (Exception ex)
            {

            }
            return strNewLine;


        }

        public static bool isStringEmpty(string strLine, string strSplit)
        {
            bool res = true;
            try
            {
                string[] arr = strLine.Split(strSplit.ToCharArray());
                foreach (string strV in arr)
                {
                    if (strV.Trim() == "")
                    {
                        continue;
                    }
                    else
                    {
                        res = false;
                    }
                }
            }
            catch (Exception ex)
            {

            }
            return res;
        }






    }
}
